#include <iostream>
#include <string>
#include "tictactoe.h"
#include <conio.h>
using namespace std;

int main()
{
	tictactoe plan;

	plan.Paintboard();

	Console::gotoxy(9, 6);
	while (1)
	{
		if (_kbhit()){

			char c = _getch();
			int a = Console::wherex();
			int b = Console::wherey();


			if (c == 'k'){
				plan.Changeboard();
				plan.Checkboard();
				plan.Paintboard();
			}
			//(3,2)

			else if	(c == 'd'&& a == 3 && b == 2){
				Console::gotoxy(9, 2);
			}
			else if (c == 'w'&& a == 3 && b == 2){
				Console::gotoxy(3, 2);
			}
			else if (c == 'a'&& a == 3 && b == 2){
				Console::gotoxy(3, 2);
			}
			else if (c == 's'&& a == 3 && b == 2){
				Console::gotoxy(3, 6);
			}

			//(9,2)

			else if (c == 'd'&& a == 9 && b == 2){
				Console::gotoxy(15, 2);
			}
			else if (c == 'w'&& a == 9 && b == 2){
				Console::gotoxy(9, 2);
			}
			else if (c == 'a'&& a == 9 && b == 2){
				Console::gotoxy(3, 2);
			}
			else if (c == 's'&& a == 9 && b == 2){
				Console::gotoxy(9, 6);
			}
			//(15,2)

			
			else if (c == 'd'&& a == 15 && b == 2){
				Console::gotoxy(15, 2);
			}
			else if (c == 'w'&& a == 15 && b == 2){
				Console::gotoxy(15, 2);
			}
			else if (c == 'a'&& a == 15 && b == 2){
				Console::gotoxy(9, 2);
			}
			else if (c == 's'&& a == 15 && b == 2){
				Console::gotoxy(15, 6);
			}

			//(15,6)

			else if (c == 'd'&& a == 15 && b == 6){
				Console::gotoxy(15, 6);
			}
			else if (c == 'w'&& a == 15 && b == 6){
				Console::gotoxy(15, 2);
			}
			else if (c == 'a'&& a == 15 && b == 6){
				Console::gotoxy(9, 6);
			}
			else if (c == 's'&& a == 15 && b == 6){
				Console::gotoxy(15, 10);
			}
			
			//(9,6)

			else if (c == 'd'&& a == 9 && b == 6){
				Console::gotoxy(15, 6);
			}
			else if (c == 'w'&& a == 9 && b == 6){
				Console::gotoxy(9, 2);
			}
			else if (c == 'a'&& a == 9 && b == 6){
				Console::gotoxy(3, 6);
			}
			else if (c == 's'&& a == 9 && b == 6){
				Console::gotoxy(9, 10);
			}

			//(3,6)

			else if (c == 'd'&& a == 3 && b == 6){
				Console::gotoxy(9, 6);
			}
			else if (c == 'w'&& a == 3 && b == 6){
				Console::gotoxy(3, 2);
			}
			else if (c == 'a'&& a == 3 && b == 6){
				Console::gotoxy(3, 6);
			}
			else if (c == 's'&& a == 3 && b == 6){
				Console::gotoxy(3, 10);
			}

			//(3,10)

			else if (c == 'd'&& a == 3 && b == 10){
				Console::gotoxy(9, 10);
			}
			else if (c == 'w'&& a == 3 && b == 10){
				Console::gotoxy(3, 6);
			}
			else if (c == 'a'&& a == 3 && b == 10){
				Console::gotoxy(3, 10);
			}
			else if (c == 's'&& a == 3 && b == 10){
				Console::gotoxy(3, 10);
			}

			//(9,10)

			else if (c == 'd'&& a == 9 && b == 10){
				Console::gotoxy(15, 10);
			}
			else if (c == 'w'&& a == 9 && b == 10){
				Console::gotoxy(9, 6);
			}
			else if (c == 'a'&& a == 9 && b == 10){
				Console::gotoxy(3, 10);
			}
			else if (c == 's'&& a == 9 && b == 10){
				Console::gotoxy(9, 10);
			}

			//(15,10)

			else if (c == 'd'&& a == 15 && b == 10){
				Console::gotoxy(15, 10);
			}
			else if (c == 'w'&& a == 15 && b == 10){
				Console::gotoxy(15, 6);
			}
			else if (c == 'a'&& a == 15 && b == 10){
				Console::gotoxy(9, 10);
			}
			else if (c == 's'&& a == 15 && b == 10){
				Console::gotoxy(15, 10);
			}
			else
				break;
		}

	}
	
	cin.get();
	return 0;

}
